home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / sframework / plugins / Demo.vbs-disabled < prev    next >
Encoding:
Text File  |  2004-09-09  |  10.2 KB  |  293 lines

  1. 'FMA Script Framework Core Plugin
  2. 'Demo
  3. 'A "simple" demo plugin
  4.  
  5. 'This plugin will demonstrate the possibilities a script developer has
  6. 'when using this framework.
  7. 'Currently demonstrated and working properly:
  8. '-(Sub)Menus
  9.  
  10. 'TODO:
  11. '    -Demonstrate EventManager   (not demonstrated yet)
  12. '        -EventManager.RegisterEvent "<eventname>", "<command to execute>", <plugin-object>
  13. '        -EventManager.DeregisterAll Me
  14. '        -EventManager.DeregisterAllFromLL <ll>
  15. '        -EventManager.OnEvent <eventname>, Array(<argument1>, <argument2>, ...)
  16. '        -Script Events triggered by FMA
  17. '    -Demonstrate KeyManager     (not demonstrated yet)
  18. '        -KeyManager.RegisterKey "<key>", <state>, "<command to execute>", <plugin-object>
  19. '        -KeyManager.DeregisterAll
  20. '        -KeyManager.DeregisterAllFromLL <LinkedList>
  21. '        -KeyManager.OnKey <key>
  22. '        -KEY_* constants
  23. '    -Demonstrate accesories menu
  24. '        -Handled by ManagedMenu   (see menu demo)
  25. '            -am.Clear
  26. '            -am.Init
  27. '            -am.AddItem
  28. '            -am.NextState
  29. '            -am.Clear
  30. '            -am.SetTitle
  31. '        -Might be handled by ManagedMenu
  32. '            -am.ClearMenu           (not demonstrated yet)
  33. '            -am.Selected            (not demonstrated yet)
  34. '            -am.DlgOption           (not demonstrated yet)
  35. '        -Not handled by ManagedMenu
  36. '            -am.DlgMsgBox
  37. '            -am.DlgYesNo
  38. '            -am.DlgOnOff
  39. '            -am.DlgPercent
  40. '            -am.DlgInputStr
  41. '            -am.DlgInputInt
  42. '            -am.DlgInformation
  43. '            -am.DlgFeedback
  44. '            -am.DlgForm             (feature not implemented in FMA)
  45. '    -Demonstrate ADT's          (not demonstrated yet)
  46. '        -Hash
  47. '        -LinkedList
  48. '        -Stack
  49. '    -Demonstrate QuickSort      (not demonstrated yet)
  50. '        -QuickSort
  51. '        -Comparator
  52. '        -DataClass
  53. '    -Demonstrate Util Class     (not demonstrated yet)
  54. '        -Sleep
  55. '        -CreateObject
  56. '        -SetStandbyScreenText
  57. '        -WaitForAppLoad
  58. '    -Demonstrate Settings Class (not demonstrated yet)
  59. '        -Settings( key ) [= value]
  60. '    -Demonstrate ActiveXManager (not demonstrated yet)
  61.  
  62. Class Demo
  63.     
  64.     'myself
  65.     Private m_Self
  66.     'my menus
  67.     Private mainMenu    'Main plugin menu
  68.     Private demoSubMenu 'Demo submenu
  69.     Private amSubMenu   'am.Dlg* demonstration sub menu
  70.     
  71.     'not needed here
  72.     Sub Class_Initialize()
  73.     End Sub
  74.     Sub Class_Terminate()
  75.     End Sub
  76.     
  77.     'Some info about the plugin
  78.     Public Property Get SHOWABLE 'Do I have a menu?
  79.         SHOWABLE    = True
  80.     End Property
  81.     Public Property Get TITLE 'What's my name?
  82.         TITLE       = "Demo Plugin"
  83.     End Property
  84.     Public Property Get DESCRIPTION 'What's my purpose?
  85.         DESCRIPTION = "This plugin has the purpose of plugin developer information."
  86.     End Property
  87.     Public Property Get AUTHOR 'Who created me?
  88.         AUTHOR      = "streawkceur"
  89.     End Property
  90.     Public Property Get URL 'Were can I be found? Where can you get more information?
  91.         URL         = "http://fma.xinium.com/"
  92.     End Property
  93.     
  94.     'Who am I? The Property Self will be set (once) after the plugin is loaded
  95.     Public Property Let Self (s)
  96.         m_Self = s
  97.         
  98.         'The Property Let Self sub is a good place to initialize your menus.
  99.         'At least in the case of static menus. When your menus are changing, you
  100.         'might initialize them each time Show() is called
  101.         
  102.         '===> Init the plugins Main Menu
  103.         'Our Main Menu is a ManagedMenu
  104.         'The Function Util.CreateObject accepts the classname from which the object
  105.         'should be created and the global accessible object variable name, from which
  106.         'the object can be accessed.
  107.         Set mainMenu = New ManagedMenu
  108.         'A ManagedMenu has to know its items, which will be passed within a LinkedList
  109.         'and its title, which will be set further down.
  110.         Dim llist, bi
  111.         Set llist = New LinkedList
  112.         bi = llist.BackInserter
  113.         'The BackInserter will append the given item at the
  114.         'LinkedList each time you assign an item to it.
  115.         'Each menu item consists of an Array with 2 elements (title, command).
  116.         'Note that you must call am.Update each time an item was selected, otherwise
  117.         'the menu will hang up. You may also call am.Update in a Sub that shall be called.
  118.         'If we want to assign our own object methods as a command, the command looks like: m_Self & ".Method"
  119.         bi.Item = Array("Submenu",   m_Self & ".SubMenu")
  120.         bi.Item = Array("Dialogues", m_Self & ".AMMenu")
  121.         'Transfer the items list to the menu object
  122.         mainMenu.SetList llist
  123.         'Set the menu's title
  124.         mainMenu.Title = TITLE
  125.         
  126.         '===> Init the demo submenu
  127.         Set demoSubMenu = New ManagedMenu
  128.         'We can reuse our variables "llist" and "bi" here
  129.         Set llist = New LinkedList
  130.         bi = llist.BackInserter
  131.         bi.Item = Array("Debug Message 1", "Debug.DebugMsg ""demo1""" & vbCrLf & "am.Update")
  132.         bi.Item = Array("Debug Message 2", "Debug.DebugMsg ""demo2""" & vbCrLf & "am.Update")
  133.         
  134.         demoSubMenu.SetList llist
  135.         demoSubMenu.Title = "Sub Menu"
  136.         
  137.         '===> Init the Accessories Demo Menu
  138.         Set amSubMenu = New ManagedMenu
  139.         Set llist = New LinkedList
  140.         bi = llist.BackInserter
  141.         bi.Item = Array("DlgMsgBox",      m_Self & ".DlgMsgBox")
  142.         bi.Item = Array("DlgYesNo",       m_Self & ".DlgYesNo")
  143.         bi.Item = Array("DlgOnOff",       m_Self & ".DlgOnOff")
  144.         bi.Item = Array("DlgPercent",     m_Self & ".DlgPercent")
  145.         bi.Item = Array("DlgInputStr",    m_Self & ".DlgInputStr")
  146.         bi.Item = Array("DlgInputInt",    m_Self & ".DlgInputInt")
  147.         bi.Item = Array("DlgInformation", m_Self & ".DlgInformation")
  148.         bi.Item = Array("DlgFeedback",    m_Self & ".DlgFeedback")
  149.         amSubMenu.SetList llist
  150.         amSubMenu.Title = "Accessrs. Menu"
  151.     End Property
  152.     Public Property Get Self
  153.         Self = m_Self
  154.     End Property
  155.     
  156.     'Display me. Eventually put a menu on the screen
  157.     Sub Show()
  158.         'We want to display our MainMenu
  159.         mainMenu.ShowMenu
  160.     End Sub
  161.     
  162.     Sub SubMenu()
  163.         'We want to display our DemoSubMenu
  164.         demoSubMenu.ShowMenu
  165.     End Sub
  166.     
  167.     Sub AMMenu()
  168.         amSubMenu.ShowMenu
  169.     End Sub
  170.     
  171.     Sub DlgMsgBox()
  172.         'Usage: am.DlgMsgBox "<message>", <timeout secs>
  173.         '0 timeout will disable the timeout
  174.         
  175.         'The MsgBox will stay until the timout is reached and then fall back
  176.         'to the NextState unless you call another am.* Sub like am.Update and bring
  177.         'the menu to another state manually.
  178.         
  179.         '<next_state> Accept    Reject
  180.         '0            Previous  Previous
  181.         '1            Wait      Previous
  182.         '2            Wait      Wait
  183.         '3            Previous  Wait
  184.         '4            Cancel    Previous
  185.         '5            Cancel    Wait
  186.         '6            Cancel    Cancel
  187.         '7            Previous  Cancel
  188.         '8            Wait      Cancel
  189.         '-Previous will most probable quit to the phones connection -> accessories menu
  190.         '-Cancel will quit the whole menu and return to the phones standy screen (until you call am.Update/am.*)
  191.         '-Wait will just stay at the dialogue screen (until you call am.Update/am.*)
  192.         ' Wait is a generally good NextState. This will prevent the phone to fall back
  193.         ' to other states (standby, accessories menu) and you are the only one defining
  194.         ' what's displayed and what's not
  195.         
  196.         'We have to "show" an empty dummy menu. That's because FMA executes the command
  197.         'that's stored in am.Back when a dialogue is quitted via the back button or it times out.
  198.         'As the back button is managed in the ManagedMenu class,  FMA would call am.Back,
  199.         'which will quit the last menu that was displayed before the dialogue.
  200.         'Putting this empty dummy menu will only quit this dummy and then show the last menu before the dialogue.
  201.         EmptyMenu.ShowMenu
  202.         am.DlgMsgBox "Demo text", 5
  203.         
  204.         'If you want to react yourself when the user quits the dialogue or when the dialoge
  205.         'times out, you should to it like this:
  206.         'EmptyMenu.ShowMenu
  207.         'am.Back = Self & ".DlgMsgBoxQuit" 'Mangage the menu quit by ourselves
  208.         'am.DlgMsgBox "Demo text", 5 'Put the dialogue
  209.     End Sub
  210.     Sub DlgMsgBoxQuit
  211.         Debug.DebugMsg "Dialogue quitted or timed out" 'Here you can do some stuff...
  212.         MenuStack.Top.Quit 'Remove emtpy menu
  213.     End Sub
  214.     
  215.     Sub DlgYesNo()
  216.         'Usage: am.DlgYesNo "<message>", "<command>", <timeout secs>
  217.         'For more detailed comments look at Sub DlgMsgBox.
  218.         EmptyMenu.ShowMenu
  219.         am.DlgYesNo "Do you like this demo?", Self & ".DlgYesNoResult", 5
  220.     End Sub
  221.     Sub DlgYesNoResult( answer )
  222.         If answer = 1 Then
  223.             Debug.DebugMsg "DlgYesNoResult: Yes, you do!"
  224.         Else 
  225.             Debug.DebugMsg "DlgYesNoResult: No, you don't!"
  226.         End If
  227.         MenuStack.Top.Quit 'Remove emtpy menu
  228.     End Sub
  229.     
  230.     Sub DlgOnOff()
  231.         'Usage: am.DlgYesNo "<title>", "<command>", <default: 0/1>
  232.         EmptyMenu.ShowMenu
  233.         am.DlgOnOff "Light on?", Self & ".DlgOnOffResult", 1
  234.     End Sub
  235.     Sub DlgOnOffResult( answer )
  236.         If answer = 1 Then
  237.             Debug.DebugMsg "DlgOnOffResult: On!"
  238.         Else
  239.             Debug.DebugMsg "DlgOnOffResult: Off!"
  240.         End If
  241.         MenuStack.Top.Quit 'Remove emtpy menu
  242.     End Sub
  243.     
  244.     Sub DlgPercent()
  245.         'Usage: am.DlgPercent "<title>", "<command>", <steps: 0-100>, <pos: 0-10>
  246.         EmptyMenu.ShowMenu
  247.         am.DlgPercent "Percent demo", Self & ".DlgPercentResult", 10, 4
  248.     End Sub
  249.     Sub DlgPercentResult( percent, final )
  250.         Debug.DebugMsg "DlgPercentResult percent: " & percent
  251.         Debug.DebugMsg "DlgPercentResult final:   " & final
  252.         If final = 1 Then MenuStack.Top.Quit 'Remove emtpy menu
  253.     End Sub
  254.     
  255.     Sub DlgInputStr()
  256.         'Usage: am.DlgInputStr "<title>", "<prompt>", <maxlen>, "<defaultstring>", "<command>"
  257.         EmptyMenu.ShowMenu
  258.         am.DlgInputStr "InputStr demo", "Prompt:", 16, "Default", Self & ".DlgInputStrResult"
  259.     End Sub
  260.     Sub DlgInputStrResult( input )
  261.         Debug.DebugMsg "DlgInputStrResult: " & input
  262.         MenuStack.Top.Quit 'Remove emtpy menu
  263.     End Sub
  264.     
  265.     Sub DlgInputInt()
  266.         'Usage: am.DlgInputInt "<title>", "<prompt>", <minval>, <maxval>, <defaultval>, "<command>"
  267.         EmptyMenu.ShowMenu
  268.         am.DlgInputInt "InputInt demo", "Prompt:", 0, 42, 23, Self & ".DlgInputIntResult"
  269.     End Sub
  270.     Sub DlgInputIntResult( input )
  271.         Debug.DebugMsg "DlgInputIntResult: " & input
  272.         MenuStack.Top.Quit 'Remove emtpy menu
  273.     End Sub
  274.     
  275.     Sub DlgInformation()
  276.         'Usage: am.DlgInformation "<title>", "<msg>"
  277.         EmptyMenu.ShowMenu
  278.         am.DlgInformation "DlgInfo demo", "Information dialogue demo"
  279.     End Sub
  280.     
  281.     Sub DlgFeedback()
  282.         'Usage: am.DlgFeedback "<title>", "<command>"
  283.         'Warning: the associated command seems to be never called. FMA only gets an *EAII: 0 instead of *EAII: 13,1
  284.         EmptyMenu.ShowMenu
  285.         am.DlgFeedback "DlgFeedbck demo", Self & ".DlgFeedbackResult"
  286.     End Sub
  287.     Sub DlgFeedbackResult()
  288.         Debug.DebugMsg "DlgFeedbackResult"
  289.         MenuStack.Top.Quit 'Remove emtpy menu
  290.     End Sub
  291.  
  292. End Class
  293.